<template>
  <div>
    <el-form ref="form" :model="productLine" label-width="80px" class="edit">
      <el-form-item label="产品线名 :">
        <el-input v-model="productLine.name" maxlength="10" show-word-limit></el-input>
      </el-form-item>
      <el-form-item label="是否启用 :">
        <el-switch
          class="switch"
          v-model="productLine.status"
          active-color="#00A854"
          active-text="启用"
          :active-value="1"
          inactive-color="#F04134"
          inactive-text="禁用"
          :inactive-value="0"
        ></el-switch>
      </el-form-item>
      <el-form-item label="具体描述 :">
        <el-input type="textarea" autosize placeholder="请输入对该产品线的描述" v-model="productLine.description"></el-input>
      </el-form-item>
      <el-button type="danger" @click="conserve()" class="btnConserveAdd">保存</el-button>
      <el-button type="success" @click="close()" class="btnCloseAdd">退出</el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "add",
  data(){
    return {
      productLine:{
        name:'',
        status:1,
        addTime:'',
        description:'',
      }
    }
  },
  methods:{
    conserve(){
      let date = new Date();
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let m = date.getMinutes();
      m = m < 10 ? "0" + m : m;
      let s = date.getSeconds();
      s = s < 10 ? "0" + s : s;
      this.productLine.addTime = y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
      console.log(this.productLine.addTime)
      this.$emit('conserve',this.productLine);
    },
    close(){
      this.$emit('close');
    },
  }
}
</script>

<style scoped>
@import "../../../assets/css/basicdata.css";
</style>
